import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';

// 简易路由守卫：模仿 admin-web 的逻辑（未加载菜单则跳转登录）
export default function RequireAuth() {
  const isLoggedIn = !!localStorage.getItem('isLoggedIn');
  const hasMenuList = !!localStorage.getItem('menuList');

  if (!isLoggedIn || !hasMenuList) {
    return <Navigate to="/login" replace />;
  }

  return <Outlet />;
}